package com.sfh.cp.util.look;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewPager;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.sfh.cp.R;
import com.sfh.cp.base.AbstractBaseActivity;
import com.sfh.lib.mvp.IPresenter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * 功能描述:
 *
 * @date 2018/6/4
 */
public class LookActivity extends AbstractBaseActivity {
    @BindView(R.id.view_pager)
    HackyViewPager viewPager;
    @BindView(R.id.tvSize)
    TextView tvSize;
    ImageAdapter adapter;

    public static void startUI(Context context, int index, List<String> list) {
        Intent intent = new Intent(context, LookActivity.class);
        intent.putExtra("DATA", new ArrayList<>(list));
        intent.putExtra("Index", index);
        context.startActivity(intent);

    }

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.look_activity);
        ButterKnife.bind(this);

        ArrayList<String> list = getIntent().getStringArrayListExtra("DATA");
        int index = getIntent().getIntExtra("Index", 0);
        adapter = new ImageAdapter(list, new ImageAdapter.OnImaegCallbackItem() {
            @Override
            public void onClick() {
                finish();
            }
        });
        viewPager.setAdapter(adapter);
        viewPager.setCurrentItem(index);
        viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
                tvSize.setText((position + 1) + "/" + adapter.getCount());
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
        tvSize.setText("1/" + list.size());
    }

    @Override
    public IPresenter getPresenter() {
        return null;
    }
}
